package model;

public class Orientation 
{
	private static int ZAXIS = 0;
	private static int XAXIS = 1;
	private static int YAXIS = 2;
	private static float MARGIN = 10;             
	
	private float[] _lastAxis;
	
	public Orientation(float[] axis)
	{
		_lastAxis = axis;
	}
	
	public void setOrientation(float[] axis)
	{
		_lastAxis = axis;
	}
	
	public boolean checkOrientation(float[] newAxis)
	{
		return 
				checkAxis(_lastAxis[ZAXIS], newAxis[ZAXIS]) && 
				checkAxis(_lastAxis[XAXIS], newAxis[XAXIS]) && 
				checkAxis(_lastAxis[YAXIS], newAxis[YAXIS]);
	}
	
	private boolean checkAxis(float lastValue, float newValue)
	{
		return Math.abs(lastValue - newValue) <= MARGIN;
	}
}
